package com.nas.crocus.domain;

import java.util.Collection;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "Pasajero")
public class Pasajero {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "pasajeroId")
    private Long id;
    
    @ManyToOne
    @JoinColumn(name = "registroPasajeroId")
    private RegistroPasajero registroPasajero;
    
    @ManyToOne
    @JoinColumn(name = "personaId")
    @Basic(fetch = FetchType.EAGER)
    private Persona persona;
    
    @ManyToOne
    @JoinColumn(name = "pasajeroParentId")
    @Basic(fetch = FetchType.EAGER)
    private Pasajero acompanianteDe;
    
    @OneToMany(mappedBy = "acompanianteDe",  cascade = CascadeType.ALL)
    private Collection <Pasajero> acompaniantes;
    
    @Column(name = "pasajeroObservacion")
    private String observacion;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }


    /**
     * @return the registroPasajero
     */
    public RegistroPasajero getRegistroPasajero() {
        return registroPasajero;
    }

    /**
     * @param registroPasajero the registroPasajero to set
     */
    public void setRegistroPasajero(RegistroPasajero registroPasajero) {
        this.registroPasajero = registroPasajero;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    public Pasajero getAcompanianteDe() {
        return acompanianteDe;
    }

    public void setAcompanianteDe(Pasajero acompanianteDe) {
        this.acompanianteDe = acompanianteDe;
    }

    public String getObservacion() {
        return observacion;
    }

    public void setObservacion(String observacion) {
        this.observacion = observacion;
    }

    public Collection<Pasajero> getAcompaniantes() {
        return acompaniantes;
    }

    public void setAcompaniantes(Collection<Pasajero> acompaniantes) {
        for (Pasajero pasajero : acompaniantes) {
            pasajero.setAcompanianteDe(this);
        }
        this.acompaniantes = acompaniantes;
    }
    
    
}
